def path = this.args[0]

def file = new File(path)

def result = [:]

file.eachLine{line->
    def splitted = line.split('\t')
    if(!result.containsKey(splitted.size())){result.put(splitted.size(), [:])}
    splitted.eachWithIndex{column,index->
        if(!result[splitted.size()].containsKey(index)){result[splitted.size()].put(index, 0)}
        result[splitted.size()][index] = Math.max(result[splitted.size()][index], column.size())
    }
}

result.each{columns,tmp->
    println 'Lines with '+columns+' columns:'
    tmp.each{col,length->
        println '\tColumn '+col+':\tMax length='+length
    }
}